const http = require("http")
const fs = require("fs")
const url = require("url")

const server = http.createServer()

server.on("request", (req, res) => {
    console.log(req.url);
    // 把字符串变为 对象  就可以方便的取出传递过来的数据了
    let { pathname } = url.parse(req.url)
    console.log(pathname);
    if(pathname == "/login"){
        fs.readFile("./get.html", "utf8", (err, data) => {
            if (err) {
                throw err
            }
            res.end(data)
        })
    }
    if(pathname == "/index"){
        res.end(123)
    }
})

server.listen(8080, () => {
    console.log("服务已经成功创建在8080端口");
})